import java.util.Scanner;

public class p1047 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int l = scanner.nextInt();
        int m = scanner.nextInt();

        boolean[] marked = new boolean[l + 1];


        for (int i = 0; i < m; i++) {
            int u = scanner.nextInt();
            int v = scanner.nextInt();

            for (int j = u; j <= v; j++) {
                marked[j] = true;
            }
        }
        scanner.close();


        int remaining = 0;
        for (boolean isRemoved : marked) {
            if (!isRemoved) {
                remaining++;
            }
        }


        System.out.println(remaining);
    }
}
